package com.aquarium.ui.controller;

import android.app.Activity;
import android.os.Handler;
import android.widget.ArrayAdapter;
import android.widget.RelativeLayout;
import android.widget.Spinner;

import com.aquarium.R;
import com.aquarium.config.WaveMode;

public class WaveMotorLayout extends ModuleSwitchableLayout {

	protected Spinner mWaveModeSpinner;
	protected String mWaveType;

	public WaveMotorLayout(Activity activity, Handler handler,
			String moduleName, Class settingClass, int intentRqstCode) {
		super(activity, handler, moduleName, settingClass, intentRqstCode);

		mWaveModeSpinner = new Spinner(mView.getContext());
		RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
				LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
		params.addRule(RelativeLayout.BELOW, R.id.radio_group);
		mWaveModeSpinner.setLayoutParams(params);
		ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
				mView.getContext(), R.array.wave_mode_array,
				android.R.layout.simple_spinner_item);
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		mWaveModeSpinner.setAdapter(adapter);

		mSettingLayout.addView(mWaveModeSpinner);
	}

	public int getCurrentWaveModeInt() {
		return mWaveModeSpinner.getSelectedItemPosition() + 1;
	}

	public String getCurrentWaveModeString() {
		int mode = mWaveModeSpinner.getSelectedItemPosition() + 1;
		return WaveMode.getWaveModeString(mode);
	}
}
